package com.smartlink.service;

import com.smartlink.dao.LoginDao;
import com.smartlink.dao.TeacherDao;
import com.smartlink.pojo.Teacher;
import com.smartlink.util.PasswordUtil;

public class TeacherService {
	private TeacherDao teacherDao;
	private LoginDao loginDao;

	public boolean save(Teacher teacher) {
		// 检测是否存在
		if (loginDao.teacherLogin(teacher.getJobNumber()) == null) {
			// 密码加密
			String password = PasswordUtil.codec(teacher.getPassword());
			teacher.setPassword(password);
			// 保存数据库
			teacherDao.insert(teacher);
			return true;
		}

		return false;
	}

	public LoginDao getLoginDao() {
		return loginDao;
	}

	public void setLoginDao(LoginDao loginDao) {
		this.loginDao = loginDao;
	}

	public TeacherDao getTeacherDao() {
		return teacherDao;
	}

	public void setTeacherDao(TeacherDao teacherDao) {
		this.teacherDao = teacherDao;
	}

}
